<?php
$sum = 1;
function fn($n){
     $GLOBALS['sum'] = $GLOBALS['sum']*$n;
     $n--;
     if($n!=1){
         fn($n);
     }  
     return $GLOBALS['sum'];
}
echo fn(5);

echo "<hr>";

function fn2($v){
    if($v ==1){
        return 1;
    }
    $e = $v * fn2($v-1);
    return $e;
    
}
echo fn2(4);


echo "<hr>";
function fn3($n){
    if($n>2){
        $re = fn3($n-1) + fn3($n-2); 
        return $re;
    }else{
        return 1;
    }
}
echo fn3(5);
            
